package com.hzdl.car.sqlprovider;

import com.hzdl.car.util.Common;
import com.hzdl.car.vo.CarVo;
import org.apache.ibatis.jdbc.SQL;

public class CarSqlProvider {
    public String findCar(CarVo carVo){
        return new SQL(){{
            SELECT("*");
            FROM("bus_car");
            if(!Common.isEmpty(carVo.getCarNumber())){
                WHERE("carNumber like concat('%',#{carNumber},'%')");
            }
            if(!Common.isEmpty(carVo.getCarType())){
                WHERE("carType like concat('%',#{carType},'%')");
            }
            if(!Common.isEmpty(carVo.getColor())){
                WHERE("color like concat('%',#{color},'%')");
            }
            if(!Common.isEmpty(carVo.getDescription())){
                WHERE("description like concat('%',#{description},'%')");
            }
            if(carVo.getIsrenting()!=null){
                WHERE("isrenting = #{isrenting}");
            }



        }}.toString();
    }
}
